<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>elementFromPoint(x, y)</title>
		<style>
			.div1 {
				width: 200px;
				height: 200px;
				background-color: red;
				color: white;
			}

			.div2 {
				position: absolute;
				top: 100px;
				left: 100px;
				width: 200px;
				height: 200px;
				background-color: blue;
				color: white;
			}
		</style>
	</head>
	<body>
		<div class="div1">
			parent
			<div class="div2">child</div>
		</div>

		<script>
			// document.elementFromPoint(x, y) 用于获取窗口内指定坐标处的元素（处嵌套最多的元素。）。
			document.addEventListener('click', function (event) {
				const elem = document.elementFromPoint(event.clientX, event.clientY)
				console.log('指定坐标处的元素', elem)
			})
		</script>
	</body>
</html>
